Passed
Branch master (9a7ed1)
by Rafael S.
01:20
created

8-bit.js ➔ describe(ꞌ8-bit from bytesꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 36
rs 8.8571
1
2
var assert = require('assert');
3
4
describe('8-bit from bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    it('should turn 1 byte to a 8-bit uInt', function() {
9
        assert.deepEqual(byteData.fromBytes(
10
            [0,0], 8),
11
            [0,0]);
12
    });
13
14
    it('should turn 1 hex byte to a 8-bit uInt (max range)', function() {
15
        assert.deepEqual(byteData.fromBytes(
16
            ["0","ff"], 8, {"base": 16}),
17
            [0, 255]);
18
    });
19
    it('should turn 1 hex byte to a 8-bit int (max range)', function() {
20
        assert.deepEqual(byteData.fromBytes(
21
            ["ff","7f"], 8, {"base": 16, "signed": true}),
22
            [-1, 127]);
23
    });
24
    it('should turn 1 hex byte to a 8-bit int (max range)', function() {
25
        assert.deepEqual(byteData.fromBytes(
26
            ["80","7f"], 8, {"base": 16, "signed": true}),
27
            [-128, 127]);
28
    });
29
    it('should turn 1 bin byte to a 8-bit uInt (max range)', function() {
30
        assert.deepEqual(byteData.fromBytes(
31
            ["00000000","11111111"], 8, {"base": 2, "signed": false}),
32
            [0, 255]);
33
    });
34
    it('should turn 1 bin byte to a 8-bit int (max range)', function() {
35
        assert.deepEqual(byteData.fromBytes(
36
            ["10000000","01111111"], 8, {"base": 2, "signed": true}),
37
            [-128, 127]);
38
    });
39
});
40